package com.pan.admin.module.api.entity.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
@Data
public class ApiKeyHistoryBillVO {
    private Long id;
    /**
     * 分组词
     */
    private String groupingWords;
    /**
     * api渠道
     */
    private String apiName;
    /**
     * 客户端id
     */
    private String apiClientId;
    /**
     * API余额
     */
    private BigDecimal balance;
    /**
     * API结余
     */
    private BigDecimal accountBalance;
    /**
     * 渠道价格
     */
    private BigDecimal apiPrice;
    /**
     * 渠道分成
     */
    private BigDecimal apiShare;
    /**
     * 消耗总数
     */
    private Long total = 0L;
    /**
     * 消耗金额
     */
    private BigDecimal amount = BigDecimal.ZERO;
    /**
     * 充值
     */
    private BigDecimal recharge = BigDecimal.ZERO;
    /**
     * 补单
     */
    private BigDecimal supplement = BigDecimal.ZERO;
    /**
     * 利润
     */
    private BigDecimal profit = BigDecimal.ZERO;
    /**
     * 正常量
     */
    private Long normal = 0L;
    /**
     * 唤醒量
     */
    private Long wake = 0L;
    /**
     * 截止统计时间
     */
    private String dateTime;
    private List<ApiKeyHistoryBillVO> children;

    public void addRecharge(BigDecimal recharge) {
        if (this.recharge == null) {
            this.recharge = BigDecimal.ZERO;
        }
        if (recharge == null) {
            recharge = BigDecimal.ZERO;
        }
        this.recharge = this.recharge.add(recharge);
    }

    public void addSupplement(BigDecimal supplement) {
        if (this.supplement == null) {
            this.supplement = BigDecimal.ZERO;
        }
        if (supplement == null) {
            supplement = BigDecimal.ZERO;
        }
        this.supplement = this.supplement.add(supplement);
    }

    public void addProfit(BigDecimal profit) {
        if (this.profit == null) {
            this.profit = BigDecimal.ZERO;
        }
        if (profit == null) {
            profit = BigDecimal.ZERO;
        }
        this.profit = this.profit.add(profit);
    }

    public void addBalance(BigDecimal balance) {
        Objects.requireNonNull(balance);
        if (this.balance == null) {
            this.balance = BigDecimal.ZERO;
        }
        this.balance = this.balance.add(balance);
    }
    public void addAccountBalance(BigDecimal accountBalance) {
        if (this.accountBalance == null) {
            this.accountBalance = BigDecimal.ZERO;
        }
        if (accountBalance == null) {
            accountBalance = BigDecimal.ZERO;
        }
        this.accountBalance = this.accountBalance.add(accountBalance);
    }

    public void addTotal(Long total) {
        if (this.total == null) {
            this.total = Long.valueOf(0L);
        }
        this.total += total;
    }

    public void addAmount(BigDecimal amount) {
        Objects.requireNonNull(amount);
        if (this.amount == null) {
            this.amount = BigDecimal.ZERO;
        }
        this.amount = this.amount.add(amount);
    }

    public void addNormal(Long normal) {
        if (this.normal == null) {
            this.normal = Long.valueOf(0L);
        }
        this.normal += normal;
    }

    public void addWake(Long wake) {
        if (this.wake == null) {
            this.wake = Long.valueOf(0L);
        }
        this.wake += wake;
    }
}
